package com.tsmti.core.common.convert;

import org.apache.commons.lang3.StringEscapeUtils;

import java.beans.PropertyEditorSupport;

/**
 * @Package：com.tsmti.core.common.convert
 * @Class：StringConvertEditor
 * @Description： TODO
 * @Author：zcw
 * @Date：Created in 2018/4/20 14:40
 * @Company:
 * @Version：
 * @Modified By:
 */
public class StringConvertEditor extends PropertyEditorSupport {
    @Override
    public void setAsText(String text) {
        setValue(text == null ? null : StringEscapeUtils.escapeHtml4(text.trim()));
    }

    @Override
    public String getAsText() {
        Object value = getValue();
        return value != null ? value.toString() : "";
    }
}
